import { Button, Table } from "antd";
import React from "react";

export default function TableCom() {
  //准备数据
  const dataSource = [
    {
      key: "1",
      name: "胡彦斌",
      age: 32,
      address: "西湖区湖底公园1号",
    },
    {
      key: "2",
      name: "吴彦祖",
      age: 42,
      address: "西湖区湖底公园1号",
    },
  ];

  //声明表格的结构
  const columns = [
    {
      title: "姓名",
      dataIndex: "name", //
      key: "name",
    },
    {
      title: "年龄",
      dataIndex: "age",
      key: "age",
    },
    {
      title: "住址",
      dataIndex: "address",
      key: "address",
    },
    {
      title: "操作",
      dataIndex: 'name',
      //渲染
      render: (value: any, row: any, index: number) => {
        return <><Button onClick={() => {
          alert(value)
        }}>显示姓名</Button><Button>修改</Button></>
      }
    },
  ];

  return (
    <div>
      <div>表格</div>
      <Table dataSource={dataSource} columns={columns} />
    </div>
  );
}
